package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.AdminAgentInfo;
import com.ruoyi.system.mapper.AdminAgentInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.AdminAgentCommandMapper;
import com.ruoyi.system.domain.AdminAgentCommand;
import com.ruoyi.system.service.IAdminAgentCommandService;

/**
 * 代理命令Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-11-11
 */
@Service
public class AdminAgentCommandServiceImpl implements IAdminAgentCommandService 
{
    @Autowired
    private AdminAgentCommandMapper adminAgentCommandMapper;

    @Autowired
    private AdminAgentInfoMapper adminAgentInfoMapper;

    /**
     * 查询代理命令
     * 
     * @param id 代理命令ID
     * @return 代理命令
     */
    @Override
    public AdminAgentCommand selectAdminAgentCommandById(Long id)
    {
        return adminAgentCommandMapper.selectAdminAgentCommandById(id);
    }

    /**
     * 查询代理命令列表
     * 
     * @param adminAgentCommand 代理命令
     * @return 代理命令
     */
    @Override
    public List<AdminAgentCommand> selectAdminAgentCommandList(AdminAgentCommand adminAgentCommand)
    {
        return adminAgentCommandMapper.selectAdminAgentCommandList(adminAgentCommand);
    }

    @Override
    public List<AdminAgentCommand> selectAdminAgentCommandListForAdmin(AdminAgentCommand adminAgentCommand) {
        return adminAgentCommandMapper.selectAdminAgentCommandListForAdmin(adminAgentCommand);
    }

    /**
     * 新增代理命令
     * 
     * @param adminAgentCommand 代理命令
     * @return 结果
     */
    @Override
    public int insertAdminAgentCommand(AdminAgentCommand adminAgentCommand)
    {
        String room = SecurityUtils.getLoginUser().getUser().getRoom();
        AdminAgentInfo adminAgentInfo = adminAgentInfoMapper.selectAdminAgentInfoByRoom(room);
        adminAgentCommand.setRoom(room);
        adminAgentCommand.setAgentId(adminAgentInfo.getId());
        adminAgentCommand.setAgentName(adminAgentInfo.getAgentName());
        return adminAgentCommandMapper.insertAdminAgentCommand(adminAgentCommand);
    }

    /**
     * 修改代理命令
     * 
     * @param adminAgentCommand 代理命令
     * @return 结果
     */
    @Override
    public int updateAdminAgentCommand(AdminAgentCommand adminAgentCommand)
    {
        return adminAgentCommandMapper.updateAdminAgentCommand(adminAgentCommand);
    }

    /**
     * 批量删除代理命令
     * 
     * @param ids 需要删除的代理命令ID
     * @return 结果
     */
    @Override
    public int deleteAdminAgentCommandByIds(Long[] ids)
    {
        return adminAgentCommandMapper.deleteAdminAgentCommandByIds(ids);
    }

    /**
     * 删除代理命令信息
     * 
     * @param id 代理命令ID
     * @return 结果
     */
    @Override
    public int deleteAdminAgentCommandById(Long id)
    {
        return adminAgentCommandMapper.deleteAdminAgentCommandById(id);
    }
}
